home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / G4C / CED / FileReq.gc < prev    next >
Encoding:
Gui4CLI script  |  1999-11-24  |  6.2 KB  |  268 lines

  1. G4C
  2.  
  3. ; FILEREQ.GC - *** THIS IS A COPY OF GUIS:TOOLS/FILEREQ.GC *****
  4. ; A multiselect File Requester with Favourites etc..
  5.  
  6. ; GuiLoad guis:tools/filereq.gc  GuiName Routine Path FavFile  -or
  7. ; GuiOpen filereq.gc  GuiName Routine Path FavFile
  8.  
  9. ; GuiName  - Name of your gui
  10. ; Routine  - Routine in your gui that will be called
  11. ; Path     - (optional) path to open at - if you want..
  12. ; FavFile  - (optional) name of the Favourites file
  13.  
  14. ; ====================================================================
  15.  
  16. ;               Globals
  17.  
  18. ; ====================================================================
  19.  
  20. WINBIG 185 16 291 213 'Choose file(s) :'
  21. WinType 11110001
  22. resinfo 8 640 256
  23. varpath ''
  24.  
  25. BOX 0 0 291 213 in icondrop
  26.  
  27.  
  28. ; ====================================================================
  29.  
  30. ;               System events
  31.  
  32. ; ====================================================================
  33.  
  34. xONLOAD  gui routine path favfile 
  35.    if  $gui > ''           ; dont pass them if you just want to load it.
  36.    and $routine > ''
  37.        guiopen filereq.gc $gui $routine $path $favfile
  38.    endif
  39.  
  40. xONRELOAD  gui routine path favfile 
  41.    guiopen filereq.gc $gui $routine $path $favfile
  42.  
  43.  
  44. XONOPEN  gui routine path favfile 
  45.    setgad filereq.gc 52/53 off
  46.    if $path > ''
  47.       lvuse filereq.gc 1
  48.       LVDir '#$path'
  49.       update filereq.gc 2 $$lv.dir      
  50.    endif
  51.    if $favfile = ""
  52.       favfile = guis:tools/fav/default
  53.    endif
  54.    
  55.  
  56. xOnRMB
  57.    if $mode = FAV
  58.       setgad filereq.gc 52/53 off
  59.       setgad filereq.gc 2/16 on
  60.       setgad filereq.gc 50/51 on
  61.       lvuse filereq.gc 1
  62.       lvmode DIR
  63.       lvdir #$$lv.dir
  64.       mode = ''
  65.    else
  66.       status
  67.    endif
  68.  
  69.  
  70. ; ====================================================================
  71.  
  72. ;               The Listview
  73.  
  74. ; ====================================================================
  75.  
  76. XLISTVIEW 9 5 213 189 "" filename "" 10 DIR
  77.    GADID 1
  78.    GADFONT #mono 8 000
  79.    if $mode = FAV
  80.       setgad filereq.gc 52/53 off
  81.       setgad filereq.gc 2/16 on
  82.       setgad filereq.gc 50/51 on
  83.       mode = ''
  84.       lvmode DIR
  85.       lvdir #$filename
  86.    else
  87.       guiclose filereq.gc
  88.       gosub $gui $routine $filereq.gc/filename  ; Give FULL variable path!
  89.    endif
  90.  
  91.  
  92. ; directory hook
  93. xlvdirhook 1
  94.    update filereq.gc 2 $filename       
  95.  
  96.  
  97. ; single click hook
  98. xlvhook 1
  99.    update filereq.gc 2 $filename
  100.  
  101.  
  102. XTEXTIN 9 194 273 14 "" txtfile "" 100
  103.    GADID 2
  104.    gadhelp 'Shows file chosen - Change the name & hit enter, to Rename it'
  105.    ifexists file $txtfile
  106.       guiclose filereq.gc
  107.       gosub $gui $routine $filereq.gc/filename
  108.    else
  109.       ezreq 'Rename $filename\nto $txtfile ?' Rename|CANCEL choice
  110.       if $choice = 1
  111.          rename $filename $txtfile
  112.          lvuse filereq.gc 1
  113.          lvdir refresh
  114.       endif
  115.    endif
  116.    
  117.  
  118. ; ====================================================================
  119.  
  120. ;               Listview control buttons
  121.  
  122. ; ====================================================================
  123.  
  124. XBUTTON 224 5 58 14 "Parent"
  125.    gadid 10
  126.    gadhelp 'CD to Parent of current dir'
  127.    lvuse filereq.gc 1
  128.    LVDir parent
  129.    update filereq.gc 2 $$lv.dir      
  130.    
  131.  
  132. XBUTTON 224 19 58 14 "Root"
  133.    gadid 11
  134.    gadhelp 'CD to Root of current dir'
  135.    lvuse filereq.gc 1
  136.    LVDir root
  137.    update filereq.gc 2 $$lv.dir      
  138.    
  139.  
  140. XBUTTON 224 33 58 14 "Disks"
  141.    gadid 12
  142.    gadhelp 'Show device list'
  143.    lvuse filereq.gc 1
  144.    LVDir disks
  145.    update filereq.gc 2 $$lv.dir      
  146.    
  147.  
  148. XBUTTON 224 47 58 14 "All"
  149.    gadid 13
  150.    gadhelp 'Select all items'
  151.    lvuse filereq.gc 1
  152.    LVDir all
  153.    update filereq.gc 2 $$lv.dir      
  154.    
  155.  
  156. XBUTTON 224 61 58 14 "None"
  157.    gadid 14
  158.    gadhelp 'Unselect all items'
  159.    lvuse filereq.gc 1
  160.    LVDir none
  161.    update filereq.gc 2 $$lv.dir      
  162.    
  163. ; ====================================================================
  164.  
  165. ;               Copy & delete
  166.  
  167. ; ====================================================================
  168.  
  169. XBUTTON 224 92 58 14 "Copy"
  170.    gadid 14
  171.    gadhelp 'Copy selected files (destination chosen through requester)'
  172.    dest = ''
  173.    ReqFile -1 -1 300 -40 'Choose destination:' DIR dest ''
  174.    if $dest > ' '
  175.       lvuse filereq.gc 1
  176.       lvaction copy $dest
  177.    endif
  178.    
  179. XBUTTON 224 78 58 14 "Delete"
  180.    gadid 14
  181.    gadhelp 'Delete selected files'
  182.    lvuse filereq.gc 1
  183.    lvaction delete REQ
  184.    
  185. XBUTTON 224 106 58 14 "MkDir"
  186.    gadid 16
  187.    gadhelp 'Create directory named $txtfile'
  188.    guiclose filereq.gc
  189.    ifexists dir $txtfile
  190.    orifexists file $txtfile
  191.       ezreq 'ERROR: Invalid directory name.\n\nEnter valid name for directory\nin the TxtIn gadget and try again..' OK ''
  192.    else
  193.       makedir $txtfile
  194.       lvdir #$txtfile
  195.       update filereq.gc 2 $filename       
  196.    endif
  197.    
  198.  
  199. ; ====================================================================
  200.  
  201. ;               Favourites control
  202.  
  203. ; ====================================================================
  204.  
  205. XBUTTON 224 123 58 14 "Fav"
  206.    gadid 50
  207.    gadhelp 'Shows Favourites listing ($favfile\)'
  208.    setgad filereq.gc 2/16 off
  209.    setgad filereq.gc 50/51 off
  210.    setgad filereq.gc 52/53 on
  211.    lvuse filereq.gc 1
  212.    lvmode MULTI
  213.    lvchange $favfile
  214.    lvsort asc
  215.    mode = FAV
  216.    
  217.  
  218. XBUTTON 224 137 29 14 "+"       ; add to favourites
  219.    gadid 51                        ; create file if it doesn't exist
  220.    gadhelp 'Add current dir to Favourites'
  221.    ifexists file $favfile
  222.       ; ok
  223.    else
  224.       .dummy = 'GUIs:'             ; got to have this one :)
  225.       copy env:.dummy $favfile
  226.    endif
  227.    lvuse filereq.gc 1
  228.    append $favfile '\n$$lv.dir'
  229.    
  230.  
  231. XBUTTON 253 137 29 14 "-"     ; delete from favourites
  232.    gadid 52
  233.    gadhelp 'Deleted selected favourites entries'
  234.    lvuse filereq.gc 1
  235.    lvmulti first
  236.    while $filename > ''
  237.        lvdel -1
  238.        lvmulti first      ; since we deleted the old 1st one
  239.    endwhile
  240.    
  241.  
  242. XBUTTON 224 151 58 14 "Save"  ; save favourites
  243.    gadid 53
  244.    gadhelp 'Save Favourites as $favfile'
  245.    lvuse filereq.gc 1
  246.    lvsave $favfile
  247.    
  248. ; ====================================================================
  249.  
  250. ;               OK & Cancel
  251.  
  252. ; ====================================================================
  253.  
  254. XBUTTON 224 168 58 25 "OK"
  255.    gadid 15
  256.    gadhelp 'Selected files will be sent to calling gui'
  257.    guiclose filereq.gc
  258.    lvuse filereq.gc 1
  259.    lvmulti first
  260.    while $filename > ''
  261.       gosub $gui $routine $filereq.gc/filename
  262.       lvmulti off
  263.       lvmulti next
  264.    endwhile
  265.    
  266.  
  267.  
  268.